package domain.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import domain.web.model.Category;
import domain.web.model.CategoryF;
import domain.web.model.ProductView;
import domain.web.service.ProductService;
import domain.web.service.SearchService;

/**
 * @author tvo35
 * 
 */

@Controller
@RequestMapping("data")
public class DataController {
	
	@Autowired
	private ProductService productService;
	@Autowired
	private SearchService searchService;
	
	@RequestMapping(value = "/categories", method = RequestMethod.POST)
	@ResponseBody
	public List<CategoryF> getCategories() {
		return productService.getCategories();
	}
	
	@RequestMapping(value = "/breadcrumbs/{id}", method = RequestMethod.POST)
	@ResponseBody
	public List<Category> getBreadcrumbs(@PathVariable("id") long id) {
		return productService.getBreadcrumbsCategories(id);
	}
	
	@RequestMapping(value = "/list/{id}", method = RequestMethod.POST)
	@ResponseBody
	public List<ProductView> getViewList(@PathVariable("id") long id) {
		return searchService.searchList(id);
	}
	
}

